<div class="division">
<form>
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tbody>
  <tr>
    <th><em class="c-red">*</em><{t}>付款人类型：<{/t}></td>
    <td colspan=2>
		<span>
			<input class='c-type' type='radio' name='c_type' value='0' checked><{t}>Юр. лицо<{/t}>
			<input class='c-type' type='radio' name='c_type' value='2' <{if $company.c_type == '2'}> checked<{/if}>><{t}>ИП<{/t}>
			<input class='c-type' type='radio' name='c_type' value='3' <{if $company.c_type == '4'}> checked<{/if}>><{t}>个人<{/t}>
		</span>
    </td>
  </tr>
  <tr>
    <th><em class="c-red">*</em><{t}>付款人名称：<{/t}></td>
    <td>
		<input id='com_name' class="ad_in1" type="text" name='name' value="<{$company.name}>"/>
    </td>
  </tr>
  <tr>
    <th><{t}>税务登记号:<{/t}></td>
    <td>
		<input id='com_taxno' class="ad_in1" type="text" name='company_taxno' value="<{$company.taxno}>"/>
    </td>
  </tr>
  <tr>
	<th>&nbsp;</th>
    <td>
		<button class="btn company_submit" type="submit"><span><span>保存</span></span></button>
	</td>
  </tr>

  </tbody>
</table>
</form>
</div>

<script>

//保存付款人信息
$$('.company_submit').addEvent('click',function(e){
	e.stop();
	var _form=this.getParent('form');
	new Request({
	method:'post',
	url: '<{link app=b2c act=save_company ctl=admin_order}>',
	data: _form.toQueryString(),
	onSuccess: function(re) {
		var rs;
		try{
			rs = JSON.parse(re);
		} catch (ex) {}
		if(rs.error)
		{
			alert(rs.error);
			return;
		}
		else
		{
			$('member_company').innerHTML = rs.content;
			company_change();
		}
	}
	}).send();
});

function company_change()
{
	var url_area3 = 'index.php?app=b2c&ctl=admin_order&act=getCompany';

    var addlistRadios3=$$('input[name^=company_id','receiver');
    if(addlistRadios3.length){

        addlistRadios3.addEvent('click', function(e,edit){
                this.set('checked',true);
                var _value=this.value;

                if(_value!='0'){
                    if(edit){
                       $('checkout-company').show();
                    }
                    else $('checkout-company').hide();
                }else{
                    $('checkout-company').show();
				}


                new Request.HTML({
                    url:url_area3,
                    update:'checkout-company',
                    onRequest:function(){
                      $('checkout-company').set('html','<div class="font-green">loading...</div>');
                    },
                    onComplete:function(){

                    }}).get({'company_id':_value,'member_id':$E('input[name^=member_id]').getValue()?$E('input[name^=member_id]').getValue():null});
            });

		if ($E('input[name^=def_company]') == null)
			addlistRadios3[0].fireEvent('click');
		else
		{
			addlistRadios3.each(function(el, index){
				if ($(el).getValue() == $E('input[name^=def_company]').getValue())
				{
					addlistRadios3[index].fireEvent('click');
				}
			});
		}
       addlistRadios3.getLast().addEvent('click',$('checkout-company').show.bind($('checkout-company')));
   }

	$$('.companyedit','receiver').addEvent('click', function(e){
		e.stop();
		this.getPrevious('input[name^=company_id').fireEvent('click',[e,true]);
	});
}
</script>